﻿@{
	Layout = "~/Views/Shared/_Layout.cshtml";
}

@using Hangerd.Mvc.Extensions;

@model dPet.Web.Hospital.ViewModels.ServiceItemModel

<div>
	<div class="page-header">
		<h3>编辑服务项</h3>
	</div>

	@using (Html.BeginForm("SaveServiceItem", "Service", FormMethod.Post, new { onsubmit = "return check_form()" }))
	{
		<div class="panel panel-default">
			<div class="panel-heading">
				&nbsp;
			</div>

			<div class="panel-body form-horizontal">
				@Html.Hidden("Id", Model.ServiceItem.Id)
				@Html.Hidden("HospitalId", Model.ServiceItem.HospitalId)

				<div class="form-group">
					<label for="Name" class="col-md-1 control-label">名　称</label>
					<div class="col-md-3">
						@Html.TextBox("Name", Model.ServiceItem.Name, new { @class = "form-control", placeholder = "请输入服务项名称" })
					</div>
				</div>

				<div class="form-group">
					<label for="CategoryId" class="col-md-1 control-label">所属分类</label>
					<div class="col-md-3">
						<select id="CategoryId" name="Category.Id" class="form-control">
							@foreach (var category in Model.Categories)
							{
								<option value="@category.Id" @Html.IsSelected(Model.ServiceItem.Category != null && Model.ServiceItem.Category.Id == category.Id)>@category.Name</option>
							}
						</select>
					</div>
				</div>

				<div class="form-group">
					<div class="col-md-offset-1 col-sm-10">
						<button type="button" class="btn btn-default btn-sm" onclick="window.history.go(-1);"><span class="glyphicon glyphicon-chevron-left"></span> 返 回</button>
						<button type="submit" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-floppy-disk"></span> 保 存</button>
					</div>
				</div>
			</div>
		</div>
	}
</div>

@section scripts {
	<script type="text/javascript">
		$(document).ready(function () {
			set_left_nav('#ln_SKUPropertyList');
		});

		function check_form() {
			if ($.trim($("#Name").val()) == '') {
				alert("请输入服务项名称");
				$("#Name").focus();
				return false;
			}

			return true;
		}
	</script>
}